var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("AnalyticsParent"),
    a = e("AnalyticsManager"),
    i = (function (e) {
        function t() {
            var t = e.call(this) || this;
            (t.initParams = null), (t.initSuccess = !1);
            var o = typeof cocosAnalytics;
            return (t.initSuccess = "undefined" != o), t;
        }
        return (
            __extends(t, e),
            (t.prototype.init = function (e) {
                this.initParams = e;
            }),
            (t.prototype.login = function (e) {
                this.initSuccess &&
                    (e == a.EAnalyticsEvent.Start
                        ? cocosAnalytics.CAAccount.loginStart({channel: this.initParams.channel})
                        : e == a.EAnalyticsEvent.Success
                        ? cocosAnalytics.CAAccount.loginSuccess({
                              userID: this.initParams.userId,
                              age: 1,
                              sex: 0,
                              channel: this.initParams.channel
                          })
                        : e == a.EAnalyticsEvent.Fail
                        ? cocosAnalytics.CAAccount.loginFailed({channel: this.initParams.channel, reason: "登录失败"})
                        : e == a.EAnalyticsEvent.Cancel && cocosAnalytics.CAAccount.logout());
            }),
            (t.prototype.enableDebug = function (e) {
                this.initSuccess && cocosAnalytics.enableDebug(e);
            }),
            (t.prototype.raiseEvent = function (e, t, o, n) {
                this.initSuccess &&
                    (e == a.EAnalyticsEventType.Custom
                        ? this._raiseCustomEvent(t, o, n)
                        : e == a.EAnalyticsEventType.Level && this._raiseLevelEvent(t, o, n));
            }),
            (t.prototype._raiseCustomEvent = function (e, t, o) {
                e == a.EAnalyticsEvent.Start
                    ? cocosAnalytics.CACustomEvent.onStarted(t, o)
                    : e == a.EAnalyticsEvent.Success
                    ? cocosAnalytics.CACustomEvent.onSuccess(t, o)
                    : e == a.EAnalyticsEvent.Fail
                    ? cocosAnalytics.CACustomEvent.onFailed(t, o, o.failresult)
                    : e == a.EAnalyticsEvent.Cancel && cocosAnalytics.CACustomEvent.onCancelled(t, o);
            }),
            (t.prototype._raiseLevelEvent = function (e, t, o) {
                e == a.EAnalyticsEvent.Start
                    ? cocosAnalytics.CALevels.begin({level: t})
                    : e == a.EAnalyticsEvent.Success
                    ? cocosAnalytics.CALevels.complete({level: t})
                    : e == a.EAnalyticsEvent.Fail && cocosAnalytics.CALevels.failed({level: t, reason: o.reason});
            }),
            t
        );
    })(n.default);
o.default = i;
